package cn.sytton.taffecloud.serivce.auth.security.handler;

import cn.sytton.taffecloud.common.base.util.JwtUtil;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 自定义退出处理类 返回成功
 *
 * @author skyrock
 */
//@Component
public class LogoutSuccessHandlerImpl implements LogoutSuccessHandler
{
    @Resource
    private JwtUtil jwtUtil;

    @Resource
//    private LogWriter logWriter;

    /**
     * 退出处理
     */
    @Override
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
//        LoginUser loginUser = jwtFactory.getLoginUser(request);
//        if (loginUser != null) {
//            // 删除用户缓存记录
//            jwtFactory.delLoginUser(loginUser.getTokenId());
////            logWriter.logBegin(request, handler);
////            logWriter.logEnd("");
//            //todo 记录用户退出日志
//            //AsyncManager.me().execute(AsyncFactory.recordLogininfor(userName, Constants.LOGOUT, "退出成功"));
//        }
//        ResponseWriter.print(response, 200, JsonUtil.getString(ResponseResult.success()));
    }
}
